package com.xiaoxiong.text;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
import android.util.Log;

public class GetSchedule {

	private final static String Url = SchoolUrl.StuSchedularUrl;
	private static String cookie;
	private Context context;
	private Handler postHandler;
	private StringHttp stringHttp;

	public GetSchedule(Context context, Handler postHandler) {
		super();
		this.context = context;
		this.stringHttp = new StringHttp(this.context);
		this.postHandler = postHandler;
		this.getCookie();
	}

	public void getCookie() {
		SharedPreferences sp_cookies = context.getSharedPreferences(
				"test", Context.MODE_PRIVATE);
		cookie = sp_cookies.getString("logincookie", null);

		StringBuilder sb = new StringBuilder(cookie);
		sb.delete(sb.indexOf(";"), sb.length());
		sb.delete(0, sb.indexOf("=") + 1);
		cookie = sb.toString();
		Log.d("cookie", cookie);
	}

	public void Post() {

		Map<String, String> postDatas = new HashMap<String, String>();
		postDatas.put("JSESSIONID", cookie);

		stringHttp.Post(Url, postHandler, postDatas);
	}

}